import 'package:bruno/bruno.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../AppConfig/Config.dart';
import 'InitiateComplaint.dart';

class ComplaintService extends StatefulWidget {

  const ComplaintService({super.key, });

  @override
  State<ComplaintService> createState() => _ComplaintServiceState();
}

class _ComplaintServiceState extends State<ComplaintService> {
  int chooseType=1;
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(

      backgroundColor: MyColors.backgreyColor,
        appBar: AppBar(
        title:Text( "投诉服务",style: TextStyle(fontWeight: FontWeight.w300,fontSize: 16.sp),),
        backgroundColor: Colors.white,
        centerTitle: true,
        ),
      floatingActionButton:Container(
        margin: EdgeInsets.only(right: 10.w,bottom: 80.h),
        width: 100.w,
        height: 40.0,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            begin: Alignment.topCenter,
            end: Alignment.bottomCenter,
            colors: [MyColors.themeColor, Color.fromRGBO(239,160,82,1)], // 设置渐变颜色
          ),
          borderRadius: BorderRadius.circular(30.0), // 设置圆角
        ),
        child: FloatingActionButton(
          onPressed: () {
            // 在这里处理悬浮按钮被点击时的操作
            Navigator.push(context,
                MaterialPageRoute(builder: (context) {
                  return  InitiateComplaint(dataMap:{},
                  );
                }));
          },
          elevation: 0,
          backgroundColor: Colors.transparent,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(30.0), // 设置圆角
          ),
          child:Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Image.asset("lib/Images/OrderList/发起投诉icon.png",width: 20.w,height: 20.h,),
              Text('发起投诉', style: TextStyle(color: Colors.white),
              ),
            ],
          ) ,
        ),

      ),
      body: Column(
        children: [
          Container(
            height: 36.h,
            padding: EdgeInsets.only(top: 12.h),
            color: Colors.white,
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                SizedBox(),
                GestureDetector(
                  child:   Column(
                    children: [
                      Text("我的投诉",style: TextStyle(color: Colors.black,fontWeight: chooseType==1?FontWeight.w600:FontWeight.w100),),
                      SizedBox(height: 4.h,),
                      Container(width: 20.w,height: 2.h,color:chooseType==1? MyColors.themeColor:Colors.white,),
                    ],
                  ),
                  onTap: (){
                    setState(() {
                      chooseType=1;
                    });
                  },
                ),
              GestureDetector(
                child:  Column(
                  children: [
                    Text("我收到的投诉",style: TextStyle(color: Colors.black,fontWeight: chooseType==2?FontWeight.w600:FontWeight.w100),),
                    SizedBox(height: 4.h,),
                    Container(width: 20.w,height: 2.h,color:chooseType==2? MyColors.themeColor:Colors.white,),
                  ],
                ),
                onTap: (){
                  setState(() {
                    chooseType=2;
                  });
                },
              ),
                SizedBox(),
              ],
            ) ,
          ),
          Container(
            margin: EdgeInsets.only(left: 10.w,right: 10.w,),
            height: screenSize.height-200,
            child:ListView.builder(
                itemCount:chooseType==1? 2:3,
                itemBuilder: (context, index) {
                    return Container(
                      margin: EdgeInsets.only(top: 8.h),
                      padding: EdgeInsets.only(left: 18.w,top: 14.h,right: 9.w,bottom: 15.h),
                      decoration: BoxDecoration(
                          color: Colors.white,
                          borderRadius: BorderRadius.all(Radius.circular(10))),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Text("回单纠纷",style: TextStyle(color: Colors.black,fontWeight: FontWeight.w600),),
                              Text("2023-05-06 16:38",style: TextStyle(color: MyColors.textColor),),
                            ],
                          ),
                          SizedBox(height: 4.h,),
                          Text("司机不寄回单/丢失",style: TextStyle(color: MyColors.textColor),),
                          SizedBox(height: 4.h,),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              Text("补偿金额",style: TextStyle(color: Colors.black),),
                              Text("¥"+"100.00",style: TextStyle(color: MyColors.themeColor),),
                            ],
                          ),
                          SizedBox(height: 10.h,),
                          chooseType==1?
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceBetween,
                            children: [
                              GestureDetector(
                                child: Image.asset("lib/Images/OrderList/IMicon.png",width: 24.w,height: 24.h,),
                                onTap: (){

                                },
                              ),
                              Container(
                                height: 25.h,
                                child: Row(
                                  children: [
                                    BrnSmallMainButton(
                                      textColor: Colors.white,
                                      bgColor: MyColors.themeColor,
                                      radius: 30,
                                      width: 60.w,
                                      fontSize: 13.sp,
                                      title: '联系',
                                      onTap: () {
                                        BrnToast.show('录需求信息', context);
                                      },
                                    ),
                                    SizedBox(width: 7.h,),
                                    BrnSmallMainButton(
                                      textColor: Colors.white,
                                      bgColor: MyColors.themeColor,
                                      radius: 30,
                                      width: 60.w,
                                      fontSize: 13.sp,
                                      title: '修改',
                                      onTap: () {
                                        BrnToast.show('录需求信息', context);
                                      },
                                    ),
                                    SizedBox(width: 7.h,),
                                    BrnSmallMainButton(
                                      textColor: Colors.white,
                                      bgColor: MyColors.themeColor,
                                      radius: 30,
                                      width: 60.w,
                                      fontSize: 13.sp,
                                      title: '撤销',
                                      onTap: () {
                                        BrnToast.show('录需求信息', context);
                                      },
                                    ),
                                  ],
                                ),
                              ),

                            ],
                          ):Row(
                            mainAxisAlignment: MainAxisAlignment.end,
                            children: [
                              Container(
                                height: 25.h,
                                child: index==2?
                                BrnTagCustom(
                                  fontSize:13.sp,
                                  maxWidth:66.w,
                                  tagText: "已撤销",
                                  tagBorderRadius:BorderRadius.all(Radius.circular(30)),
                                  textPadding:EdgeInsets.only(left:8.w,right: 8.w,top: 4.h,bottom: 4.h),
                                  backgroundColor: MyColors.backgreyColor,
                                  textColor: MyColors.textColor,
                                ):
                                Row(
                                  children: [
                                    BrnSmallMainButton(
                                      textColor: Colors.white,
                                      bgColor: MyColors.themeColor,
                                      radius: 30,
                                      width: 60.w,
                                      fontSize: 13.sp,
                                      title: '同意',
                                      onTap: () {
                                        BrnToast.show('录需求信息', context);
                                      },
                                    ),
                                    SizedBox(width: 7.h,),
                                    BrnSmallMainButton(
                                      textColor: Colors.white,
                                      bgColor: MyColors.themeColor,
                                      radius: 30,
                                      width: 60.w,
                                      fontSize: 13.sp,
                                      title: '拒绝',
                                      onTap: () {
                                        BrnToast.show('录需求信息', context);
                                      },
                                    ),

                                  ],
                                ),
                              ),

                            ],
                          ),
                        ],
                      ),
                    );
                }),
          ),
        ],
      ),
    );
  }
}
